/**
 * 用户信息管理
 */

import api from '../api'
import http from '../http'


const permission = {
  namespaced: true,
  state: {
    userInfo: {},
  },
  mutations: {
    setUserInfo (state, userInfo) {
      state.userInfo = userInfo
    },
  },
  actions: {
    /**
     * 获取用户信息
     * @param {*} param0 
     */
    getUserInfo ({ commit }) {
      return new Promise(async (resolve, reject) => {
        try {
          const userInfo = await http.get(api.userInfo)
          commit('setUserInfo', userInfo.data)
          resolve(userInfo.data)
        } catch (error) {
          reject(error)
        }
      })
    }

  }
}



export default permission